package com.situ.team5.kzq.recruit.dao;

import com.situ.team5.pojo.EngageInterview;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Mapper
public interface MsDAO {
    @Select("select c.major_name,f.major_kind_name,e.* from  engage_resume e " +
            "inner join config_major c on e.human_major_id=c.major_id inner join " +
            "config_major_kind f on c.major_kind_id=f.major_kind_id where  jl_status in (0,2) ")
    List<Map> yxjlSelectAll();


    @Select("select c.major_name,f.major_kind_name,m.* from  engage_resume m inner join" +
            " config_major c on m.human_major_id=c.major_id  inner join " +
            " config_major_kind f on c.major_kind_id=f.major_kind_id"+
            " where m.res_id=#{value}")
    Map yxjlSelectAllOne(int id);


    //添加面试表
    @Insert("<script>" +
            "\tinsert into engage_interview (\n" +
            "\t\t\t<if test=\"human_name != null\">human_name,</if>\n" +
            "\t\t\t<if test=\"human_major_id != null\">human_major_id,</if>\n" +
            "\t\t\t<if test=\"image_degree != null\">image_degree,</if>\n" +
            "\t\t\t<if test=\"native_language_degree != null\">native_language_degree,</if>\n" +
            "\t\t\t<if test=\"foreign_language_degree != null\">foreign_language_degree,</if>\n" +
            "\t\t\t<if test=\"response_speed_degree != null\">response_speed_degree,</if>\n" +
            "\t\t\t<if test=\"EQ_degree != null\">EQ_degree,</if>\n" +
            "\t\t\t<if test=\"IQ_degree != null\">IQ_degree,</if>\n" +
            "\t\t\t<if test=\"multi_quality_degree != null\">multi_quality_degree,</if>\n" +
            "\t\t\t<if test=\"register_sx != null\">register_sx,</if>\n" +
            "\t\t\t<if test=\"checker_sx != null\">checker_sx,</if>\n" +
            "\t\t\t<if test=\"registe_time_sx != null\">registe_time_sx,</if>\n" +
            "\t\t\t<if test=\"check_time_sx != null\">check_time_sx,</if>\n" +
            "\t\t\t<if test=\"resume_id != null\">resume_id,</if>\n" +
            "\t\t\t<if test=\"result != null\">result,</if>\n" +
            "\t\t\t<if test=\"interview_comment != null\">interview_comment</if>\n" +
            "\t\t\t<if test=\"check_comment != null\">check_comment,</if>\n" +
            "\t\t\t<if test=\"check_status != null\">check_status</if>\n" +
            ") values("+
            "\t\t\t<if test=\"human_name != null\">#{human_name},</if>\n" +
            "\t\t\t<if test=\"human_major_id != null\">#{human_major_id},</if>\n" +
            "\t\t\t<if test=\"image_degree != null\">#{image_degree},</if>\n" +
            "\t\t\t<if test=\"native_language_degree != null\">#{native_language_degree},</if>\n" +
            "\t\t\t<if test=\"foreign_language_degree != null\">#{foreign_language_degree},</if>\n" +
            "\t\t\t<if test=\"response_speed_degree != null\">#{response_speed_degree},</if>\n" +
            "\t\t\t<if test=\"EQ_degree != null\">#{EQ_degree},</if>\n" +
            "\t\t\t<if test=\"IQ_degree != null\">#{IQ_degree},</if>\n" +
            "\t\t\t<if test=\"multi_quality_degree != null\">#{multi_quality_degree},</if>\n" +
            "\t\t\t<if test=\"register_sx != null\">#{register_sx},</if>\n" +
            "\t\t\t<if test=\"checker_sx != null\">#{checker_sx},</if>\n" +
            "\t\t\t<if test=\"registe_time_sx != null\">#{registe_time_sx},</if>\n" +
            "\t\t\t<if test=\"check_time_sx != null\">#{check_time_sx},</if>\n" +
            "\t\t\t<if test=\"resume_id != null\">#{resume_id},</if>\n" +
            "\t\t\t<if test=\"result != null\">#{result},</if>\n" +
            "\t\t\t<if test=\"interview_comment != null\">#{interview_comment}</if>\n" +
            "\t\t\t<if test=\"check_comment != null\">#{check_comment},</if>\n" +
            "\t\t\t<if test=\"check_status != null\">#{check_status}</if>" +
            ")"+
            "</script>")
    void Msinset(EngageInterview e);

@Select(" select c.major_name,f.major_kind_name,m.*,\n" +
        "w.native_language_degree,w.foreign_language_degree,\n" +
        "w.response_speed_degree,w.EQ_degree,w.IQ_degree,w.multi_quality_degree,\n" +
        "w.registe_time_sx,w.resume_id ,w.interview_comment,w.check_comment,\n" +
        "w.image_degree from  engage_resume m inner join engage_interview w\n" +
        " on w.resume_id=m.res_id inner join\n" +
        "   config_major c on m.human_major_id=c.major_id inner join\n" +
        "    config_major_kind f on c.major_kind_id=f.major_kind_id\n" +
        "    where m.jl_status in (1,2) and w.ein_id in (select max(ein_id) from engage_interview  Group by human_name)\n" +
        "    ")
    //查出所有已经面试过的人的数据
      List<Map> interview_statusSelectAll();


@Update("update engage_interview set checker_sx=#{checker_sx},check_time_sx=#{check_time_sx}," +
        "check_comment=#{check_comment},check_status=#{check_status} where ein_id=#{ein_id}")
    void interview_sift_update(EngageInterview g);


    //通过id简历表和面试表连接查询
@Select("select c.major_name,f.major_kind_name,m.* ,w.* from  engage_resume m inner join \n" +
        "engage_interview w on w.resume_id=m.res_id inner join \n" +
        "config_major c on m.human_major_id=c.major_id   inner join \n" +
        "config_major_kind f on c.major_kind_id=f.major_kind_id\n" +
        " where m.res_id=#{value} and  w.ein_id in (select max(ein_id) from engage_interview  Group by human_name)")
    Map yxjlSelectAllOne2(int id);

    @Delete("delete from engage_interview  where resume_id=#{value}")
     void engage_interview_delete(int id);

    //修改面试表简历状态
    @Update("update engage_interview set check_status=#{check_status} where ein_id=#{ein_id}")
    void update_engage_interview_check_status(@Param("check_status") int jl_status,@Param("ein_id") int ein_id);
}
